package it.stasbranger.myproject.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import java.util.Date;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import org.codehaus.jackson.annotate.JsonIgnore;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllRequestss", query = "select myRequests from Requests myRequests"),
		@NamedQuery(name = "findRequestsByDate", query = "select myRequests from Requests myRequests where myRequests.date = ?1"),
		@NamedQuery(name = "findRequestsByEmail", query = "select myRequests from Requests myRequests where myRequests.email = ?1"),
		@NamedQuery(name = "findRequestsByEmailContaining", query = "select myRequests from Requests myRequests where myRequests.email like ?1"),
		@NamedQuery(name = "findRequestsByIdrequests", query = "select myRequests from Requests myRequests where myRequests.idrequests = ?1"),
		@NamedQuery(name = "findRequestsByName", query = "select myRequests from Requests myRequests where myRequests.name = ?1"),
		@NamedQuery(name = "findRequestsByNameContaining", query = "select myRequests from Requests myRequests where myRequests.name like ?1"),
		@NamedQuery(name = "findRequestsByPrimaryKey", query = "select myRequests from Requests myRequests where myRequests.idrequests = ?1") })
@Table(catalog = "mydb", name = "requests")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "MyProject/it/stasbranger/myproject/domain", name = "Requests")
@XmlRootElement(namespace = "MyProject/it/stasbranger/myproject/domain")
public class Requests implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "idrequests", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@XmlElement
	Integer idrequests;
	/**
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "date", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Date date;
	/**
	 */

	@Column(name = "name", length = 45)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String name;
	/**
	 */

	@Column(name = "email", length = 45)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String email;

	/**
	 */
	@OneToMany(mappedBy = "requests", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
	@XmlElement(name = "", namespace = "")
	java.util.Set<it.stasbranger.myproject.domain.SuppliersHasRequests> suppliersHasRequestses;

	/**
	 */
	public void setIdrequests(Integer idrequests) {
		this.idrequests = idrequests;
	}

	/**
	 */
	public Integer getIdrequests() {
		return this.idrequests;
	}

	/**
	 */
	public void setDate(Date date) {
		this.date = date;
	}

	/**
	 */
	public Date getDate() {
		return this.date;
	}

	/**
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 */
	public String getName() {
		return this.name;
	}

	/**
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 */
	public String getEmail() {
		return this.email;
	}

	/**
	 */
	public void setSuppliersHasRequestses(Set<SuppliersHasRequests> suppliersHasRequestses) {
		this.suppliersHasRequestses = suppliersHasRequestses;
	}

	/**
	 */
	@JsonIgnore
	public Set<SuppliersHasRequests> getSuppliersHasRequestses() {
		if (suppliersHasRequestses == null) {
			suppliersHasRequestses = new java.util.LinkedHashSet<it.stasbranger.myproject.domain.SuppliersHasRequests>();
		}
		return suppliersHasRequestses;
	}

	/**
	 */
	public Requests() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(Requests that) {
		setIdrequests(that.getIdrequests());
		setDate(that.getDate());
		setName(that.getName());
		setEmail(that.getEmail());
		setSuppliersHasRequestses(new java.util.LinkedHashSet<it.stasbranger.myproject.domain.SuppliersHasRequests>(that.getSuppliersHasRequestses()));
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("idrequests=[").append(idrequests).append("] ");
		buffer.append("date=[").append(date).append("] ");
		buffer.append("name=[").append(name).append("] ");
		buffer.append("email=[").append(email).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((idrequests == null) ? 0 : idrequests.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof Requests))
			return false;
		Requests equalCheck = (Requests) obj;
		if ((idrequests == null && equalCheck.idrequests != null) || (idrequests != null && equalCheck.idrequests == null))
			return false;
		if (idrequests != null && !idrequests.equals(equalCheck.idrequests))
			return false;
		return true;
	}
}
